﻿// -------------------------------------------------------------------------------------------------------------------------------
// <copyright file="CcsSparseMatrixMultiplicationOperationsProvider.cs" company="Exul">
//     Copyright (c) Exul. All rights reserved.
// </copyright>
// <author>
//     Exul
// </author>
// -------------------------------------------------------------------------------------------------------------------------------

namespace ExulLibrary.Mathematics.LinearAlgebra.Sequential.DecimalExtensions
{
    #region Usings

    using System;

    #endregion

    /// <summary>
    ///     Provides operations for <see cref="CcsSparseMatrix{T}"/> through interface.
    /// </summary>
    internal sealed class CcsSparseMatrixMultiplicationOperationsProvider : IMultiplicableMatrixOperationsProvider<decimal>
    {
        #region Implemented Interfaces

        #region IMultiplicableMatrixOperationsProvider<decimal>

        /// <summary>
        ///     Multiplies the matrix by the dense vector and stores the result in the another vector.
        /// </summary>
        /// <param name="multiplicand">
        ///     The multiplicand matrix.
        /// </param>
        /// <param name="multiplier">
        ///     The multiplier vector.
        /// </param>
        /// <param name="result">
        ///     The vector to store the result.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="multiplicand"/> is <see langword="null"/>.
        ///     <para>
        ///         --or--
        ///     </para>
        ///     <para>
        ///         <paramref name="multiplier"/> is <see langword="null"/>.
        ///     </para>
        ///     <para>
        ///         --or--
        ///     </para>
        ///     <para>
        ///         <paramref name="result"/> is <see langword="null"/>.
        ///     </para>
        /// </exception>
        public void Multiply(Matrix<decimal> multiplicand, DenseVector<decimal> multiplier, DenseVector<decimal> result)
        {
            var realMultiplicand = multiplicand as CcsSparseMatrix<decimal>;
            realMultiplicand.Multiply(multiplier, result);
        }

        #endregion

        #endregion
    }
}